// services/api.js

export const fetchPosts = async () => {
    try {
      const { data } = await useFetch('https://your-api.com/posts')
      return data
    } catch (error) {
      console.error('Failed to fetch posts:', error)
      throw error
    }
  }
  
  export const fetchPost = async (id) => {
    try {
      const { data } = await useFetch(`https://your-api.com/posts/${id}`)
      return data
    } catch (error) {
      console.error(`Failed to fetch post with id ${id}:`, error)
      throw error
    }
  }
  